import { GLTFLoader } from './GLTFLoader.js'

// 设置吊线
export function setLine () {
  // 吊线起点和终点
  const startPoint = new THREE.Vector3(5, 62, 0);
  const endPoint = new THREE.Vector3(5, 20, 0);
  // 创建线几何体
  const geometry = new THREE.BufferGeometry().setFromPoints([startPoint, endPoint]);
  
  // 创建材质
  const material = new THREE.LineBasicMaterial({ color: 0x000000 }); // 红色绳索

  return new THREE.Line(geometry, material)
}

export function updateLine () {
  const points = geometry.attributes.position.array;
  // const time = Date.now() * 0.001; // 获取当前时间，用于动画效果
  // points[4]: 修改终点位置  
  // points[4] -= 0.05
  // dgGroup.position.y -= 0.05
  // dsAndDgGroup.position.x += 0.1
  if (points[4] >= points[1]) {
    // points[4] -= 0.05
  } else if (points[4] <= 0) {
    // points[4] += 0.05
  } else {
    // points[4] += 0.05
  }
  geometry.attributes.position.needsUpdate = true; // 标记需要更新顶点数据
}